package cn.rongdao.jrkabao.ui.loan.adapter.viewholder;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.mifengkong.frtools.ui.adapter.recyclerview.FRBaseRecyclerViewHolder;

import cn.rongdao.jrkabao.R;
import cn.rongdao.jrkabao.bean.loan.MultiPushBean;
import cn.rongdao.jrkabao.ui.loan.adapter.listener.MutliPustitemClickListener;
import cn.rongdao.jrkabao.util.CommonUtil;

/**
 * Created by jack on 17/5/16
 */

public class MultiPushCompletedViewHolder extends FRBaseRecyclerViewHolder<MultiPushBean.ProductListBean> {


    private final ImageView mIcon;
    private final TextView mName;
    private final TextView mDesc;
    private final TextView mReApply;
    private final TextView mStage;
    private final TextView mAmount;
    private final View mShadow;
    private MutliPustitemClickListener mutliPustitemClickListener;

    public MultiPushCompletedViewHolder(View itemView, MutliPustitemClickListener clickListener) {
        super(itemView);
        this.mutliPustitemClickListener = clickListener;
        mIcon = findView(R.id.impc_icon);
        mName = findView(R.id.impc_name);
        mDesc = findView(R.id.impc_desc);
        mReApply = findView(R.id.impc_reapply);
        mAmount = findView(R.id.impc_amount);
        mStage = findView(R.id.impc_stage);
        mShadow = findView(R.id.impc_center_view);
    }


    @Override
    protected void onItemDataUpdated(final MultiPushBean.ProductListBean productListBean) {
        Glide.with(getContext()).load(productListBean.getOrg_pic()).into(mIcon);

        mName.setText(productListBean.getOrg_name());
        mDesc.setText(CommonUtil.timeStamp2Date(String.valueOf(productListBean.getCreate_time())));
        mAmount.setText(productListBean.getAmount());
        mStage.setText(productListBean.getStages());
        mShadow.setVisibility(productListBean.isShowCenterShaow() ? View.VISIBLE : View.GONE);

        mReApply.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mutliPustitemClickListener != null)
                    mutliPustitemClickListener.setItemCompletedAndReapplyClickListener(productListBean);
            }
        });
    }
}